// 导入组件
import Vue from 'vue';
import Router from 'vue-router';

const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}

const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace (to) {
  return VueRouterReplace.call(this, to).catch(err => err)
}

// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    mode: 'history',
    routes: [{
        path: '/',
        name: '',
        component: () => import('../views/login.vue'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/login',
        name: '登录',
        component: () => import('../views/login.vue'),
        hidden: true,
        meta: {
            requireAuth: false
        }
    }, {
        path: '/index',
        name: '首页',
        component: () => import('../views/index.vue'),
        iconCls: 'el-icon-tickets',
        children: [
          {
            path: '/varity/brand',
            name: 'Brand',
            component: () => import('../views/varity/brand.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/varity/varity',
            name: 'Varity',
            component: () => import('../views/varity/varity.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/user',
            name: 'User',
            component: () => import('../views/user/index.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/userDetail',
            name: 'UserDetail',
            component: () => import('../views/user/user.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/order',
            name: 'Order',
            component: () => import('../views/order/index.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/comment',
            name: 'Comment',
            component: () => import('../views/comment/index.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/goods/recommend',
            name: 'Recommend',
            component: () => import('../views/goods/recommend.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/goods/sellGoods',
            name: 'SellGoods',
            component: () => import('../views/goods/sellGoods.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/charts/custom',
            name: 'Custom',
            component: () => import('../views/charts/custom.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/charts/product',
            name: 'Product',
            component: () => import('../views/charts/product.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/charts/sell',
            name: 'Sell',
            component: () => import('../views/charts/sell.vue'),
            meta: {
                requireAuth: true
            }
          },
          {
            path: '/manager/num',
            name: 'ManagerNum',
            component: () => import('../views/manager/num.vue'),
            meta: {
              requireAuth: true
            }
          },
          {
            path: '/manager/order',
            name: 'ManagerOrder',
            component: () => import('../views/manager/order.vue'),
            meta: {
              requireAuth: true
            }
          },
          {
            path: '/manager/numYj',
            name: 'ManagerNumYj',
            component: () => import('../views/manager/numYj.vue'),
            meta: {
              requireAuth: true
            }
          },
          {
            path: '/manager/entry',
            name: 'ManagerEntry',
            component: () => import('../views/manager/entry.vue'),
            meta: {
              requireAuth: true
            }
          }
        ]
      }
    ]
  }
)
